package cc.autoapi.pucong.auto.flow.persistence.bo.jwt;


import cc.autoapi.pucong.auto.flow.core.root.entity.UserJwt;
import lombok.Data;

/**
 * jwt实体数据
 */
@Data
public class Claims {
    /**
     * 主题
     */
    private String sub;

    /**
     * 签发时间
     */
    private Long iat;

    /**
     * 过期时间
     */
    private Long exp;

    /**
     * JWT ID
     */
    private String jti;

    /**
     * 用户id
     */
    private String userId;

    /**
     * 用户
     */
    private UserJwt userJwt;

    public Claims(String sub, Long iat, Long exp, String jti, String userId, UserJwt userJwt) {
        this.sub = sub;
        this.iat = iat;
        this.exp = exp;
        this.jti = jti;
        this.userId = userId;
        this.userJwt = userJwt;
    }

    public String getSub() {
        return sub;
    }

    public void setSub(String sub) {
        this.sub = sub;
    }

    public Long getIat() {
        return iat;
    }

    public void setIat(Long iat) {
        this.iat = iat;
    }

    public Long getExp() {
        return exp;
    }

    public void setExp(Long exp) {
        this.exp = exp;
    }

    public String getJti() {
        return jti;
    }

    public void setJti(String jti) {
        this.jti = jti;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public UserJwt getUserJwt() {
        return userJwt;
    }

    public void setUserJwt(UserJwt userJwt) {
        this.userJwt = userJwt;
    }
    public static ClaimsBuilder builder() {
        return new ClaimsBuilder();
    }
    public static final class ClaimsBuilder {
        //主题
        private String sub;

        //签发时间
        private Long iat;

        //过期时间
        private Long exp;

        //JWT ID
        private String jti;

        //用户id
        private String userId;

        private UserJwt userJwt;


        private ClaimsBuilder() {
        }

        public ClaimsBuilder sub(String sub) {
            this.sub = sub;
            return this;
        }

        public ClaimsBuilder iat(Long iat) {
            this.iat = iat;
            return this;
        }

        public ClaimsBuilder exp(Long exp) {
            this.exp = exp;
            return this;
        }

        public ClaimsBuilder jti(String jti) {
            this.jti = jti;
            return this;
        }

        public ClaimsBuilder userId(String userId) {
            this.userId = userId;
            return this;
        }

        public ClaimsBuilder userJwt(UserJwt userJwt) {
            this.userJwt = userJwt;
            return this;
        }

        public Claims build() {
            return new Claims(
                    this.sub,
                    this.iat,
                    this.exp,
                    this.jti,
                    this.userId,
                    this.userJwt);
        }
    }
}